<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        var num = prompt('请输入班级总人数:')
        var he = 0 //求和的变量3
        var tre = 0 //平均数的变量
        for (var i = 1; i <= num; i++) {
            var zhi = prompt('第' + i + '个同学的成绩')
            he += parseFloat(zhi)
        }
        tre = he / num
        alert('班级总的分数是:' + he)
        alert('平均分是：' + tre)
    </script>
</body>

</html>